from django.shortcuts import render_to_response
from yatcs.main.models import User
from django import forms

class LoginForm(forms.Form):
	username = forms.CharField(max_length=30)
	password = forms.CharField(widget=forms.PasswordInput)      

def index(request):
	users = User.objects.all().filter(name='dgolushko')
	return render_to_response('head.html',{'users': users})
	
def login(request):
	if request.method == "POST":
		form = LoginForm(request.POST)
		if form.is_valid():
			username = form.cleaned_data['username']
			password = form.cleaned_data['password']
			passCheck = User.objects.all().filter(name=username)
			for user in passCheck:
				if user.password == password:
					return render_to_response('head.html',{'users':user})
			
	else:		
		form = LoginForm()
	return render_to_response('login.html',{'form':form})
	
def logout(request):
	pass